package com.systop.dxjj.modules.user.controller;


import com.systop.dxjj.common.pojo.ResponseResult;
import com.systop.dxjj.common.pojo.Teacher;
import com.systop.dxjj.common.pojo.User;
import com.systop.dxjj.common.utils.R;
import com.systop.dxjj.modules.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 吴健伟
 */
@RestController
@Api("用户管理模块")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * 教员登录
     */
    @PostMapping("/loginUser")
    @ApiOperation(value = "管理员登录",notes = "管理员信息")
    public R loginUser(User user){
        return userService.loginUser(user);
    }

    /**
     * 查询所有用户信息
     */
    @GetMapping("/selectAllUsers")
    @ApiOperation(value = "查询所有用户信息",notes = "用户信息")
    public R selectAllUsers(){

        return userService.selectAllUsers();
    }

    /**
     *根据id查询用户信息
     */
    @GetMapping("/selectUserById/{id}")
    @ApiOperation(value = "根据id查询用户信息",notes = "用户信息")
    public R  selectUserById(@PathVariable Integer id){

        return userService.selectUserById(id);
    }

    /**
     *根据name查询用户信息
     */
    @GetMapping("/selectUserByName/{name}")
    @ApiOperation(value = "根据name查询用户信息",notes = "用户信息")
    public R  selectUserByName(@PathVariable String name){

        return userService.selectUserByName(name);
    }

    /**
     *插入用户信息
     */
    @PostMapping("/insertUser")
    @ApiOperation(value = "插入用户信息",notes = "用户信息")
    public R  insertUser(@RequestBody User user){

        return userService.insertUser(user);
    }


    /**
     *更新用户信息
     */
    @PostMapping("/updateUser")
    @ApiOperation(value = "更新用户信息",notes = "用户信息")
    public R updateUser(@RequestBody User user){

        return userService.updateUser(user);
    }

    /**
     *删除用户信息
     */
    @GetMapping("/deleteUser/{id}")
    @ApiOperation(value = "删除用户信息",notes = "用户信息")
    public R  deleteUser(@PathVariable Integer id){

        return userService.deleteUser(id);
    }

    @PostMapping("/user/login")
    public ResponseResult login (@RequestBody User user){
        return userService.userLogin(user);
    }

}
